package com.vanke.gankclient.base

import android.databinding.ViewDataBinding
import android.support.v7.widget.RecyclerView

/**
 * @name GankClient
 * @package name：com.vanke.gankclient
 * @class describe
 * @anthor shiyuchuan
 * @time 2017/8/10 15:22
 */
abstract class BaseBindingAdapter<B : ViewDataBinding> : RecyclerView.Adapter<DataBoundViewHolder<B>>(){

    var mListener: ((pos: Int) -> Unit)? = null

    override fun onBindViewHolder(holder: DataBoundViewHolder<B>, position: Int) {
        holder.binding.root.setOnClickListener {
            mListener?.invoke(holder.adapterPosition)
        }
    }

    fun setOnItemClickListener(listener: ((pos: Int) -> Unit)){

        mListener = listener
    }
}